<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/vue-2.4.0.js"></script>
</head>
<body>
    <div id="app">
        <input type="button" value="浪一浪" @click="lang">
        <input type="button" value="停下来" @click="stop">

        <div> {{msg }} </div>
    </div>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{
                msg:"猥琐发育，别浪~~",
                IntervalId: null
            },
            methods:{

                lang: function(){

                    if(this.IntervalId != null) return

                    this.IntervalId = setInterval(() => {
                        var start = this.msg.substring(0,1)
                        var end = this.msg.substring(1)

                        this.msg = end + start
                    }, 400);
                },
                stop() {
                    clearInterval(this.IntervalId)
                    this.IntervalId = null
                }
            }
        })
    </script>
</body>
</html>
